from PyQt4.QtGui import QDialog
from PyQt4.QtGui import QComboBox
from PyQt4.QtGui import QVBoxLayout, QHBoxLayout
from PyQt4.QtGui import QDialogButtonBox
from PyQt4.QtCore import SIGNAL, Qt

class NewGameView(QDialog):

    def __init__(self, parent=None):
        super(NewGameView, self).__init__(parent)
        self.setWindowTitle('New Game')
        # combo box
        self.orderCombo = QComboBox(self)
        self.levelCombo = QComboBox(self)
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        self.buttonBox.show()
        self.initOrderCombo()
        self.initLevelCombo()
        # layout
        self.mainLayout = QVBoxLayout(self)
        self.mainLayout.addWidget(self.orderCombo)
        self.mainLayout.addWidget(self.levelCombo)
        self.mainLayout.addWidget(self.buttonBox)
        self.setLayout(self.mainLayout)
        # connect
        self.connect(self.buttonBox, SIGNAL('accepted()'), self.emitAccept)

    def initOrderCombo(self):
        self.orderCombo.addItem('First  Hand')
        self.orderCombo.addItem('Second Hand')

    def initLevelCombo(self):
        self.levelCombo.addItem('Easy')
        self.levelCombo.addItem('Normal')
        self.levelCombo.setCurrentIndex(1)


    def emitAccept(self):
        self.emit(SIGNAL('accepted(int, int)'), self.orderCombo.currentIndex(), self.levelCombo.currentIndex())